package com.touch.app.controller;

import com.touch.app.common.domain.ChatGPTRequest;
import com.touch.app.common.domain.ChatGPTResponse;
import com.touch.app.service.RequestServerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/api/openai")
public class RequestController {

    @Autowired
    private RequestServerService requestServerService;

    @PostMapping("/chat")
    @ResponseBody
    public ChatGPTResponse chat(@RequestBody ChatGPTRequest chatGPTRequest, HttpServletRequest request) {
        return requestServerService.requestServer(chatGPTRequest, request);
    }

}
